{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "  (0, 1)\t1.0\n",
      "  (1, 0)\t8.0\n",
      "  (1, 2)\t2.0\n",
      "  (2, 1)\t4.0\n",
      "  (2, 2)\t-3.0\n"
     ]
    }
   ],
   "source": [
    "import scipy.sparse as sp\n",
    "import numpy as np\n",
    "\n",
    "A = sp.lil_matrix( (4,3) )\n",
    "\n",
    "A[0,1] = 1 # 设置矩阵最上面一行的值\n",
    "\n",
    "A[1,0] = 8 # 设置矩阵最最侧一列的值\n",
    "\n",
    "A[1:3,1:3] = np.array([[0, 2],[4,-3]]) # 创建一个子矩阵\n",
    "\n",
    "print(A)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
